import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/LoginView.vue')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('@/views/RegisterView.vue'),
  },
  {
    path: '/index',
    name: 'index',
    redirect: '/index/notice',
    component: () => import('@/views/IndexView.vue'),
    children: [
      {path: 'employee', component: () => import('@/components/menus/MyEmployee.vue')},
      {path: 'roleapply', component: () => import('@/components/menus/MyRoleApply.vue')},
      {path: 'personal', component: () => import('@/components/menus/MyPersonal.vue')},
      {path: 'audit', component: () => import('@/components/menus/MyAudit.vue')},
      {path: 'detail/:id', component: () => import('@/components/menus/MyDetail.vue'), props: true},
      {path: 'notice', component: () => import('@/components/menus/MyNotice.vue')},
    ]
  },
  {
    path: '/:pathMatch(.*)',
    name: '404',
    meta: { title: '404' },
    component: () => import('@/views/404View.vue'),
  },
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
})

export default router
